package com.example.administrator.exkotlin.jetpack.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.example.administrator.exkotlin.jetpack.viewmodel.data.ViewData

/**
 * Author by lp,on 2020/8/28/028,16:43.
 * ViewModelProvider.Factory生命周期与activity无关
 * 因此可以用来创建带有构造参数的ViewModel
 */
class JetPackVMFactory(private val cout:Int) :ViewModelProvider.Factory{
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        return JetPackViewModel(ViewData(count = cout)) as T
    }
}